package com.sxf.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.sxf.dao.LinkDAO;
import com.sxf.domain.blog.Link;
import com.sxf.domain.viewbean.LinkVO;
import com.sxf.mybatis.page.Pagination;
import com.sxf.querybean.LinkQuery;
@Repository
public class LinkDAOImpl extends SuperDAOImpl implements LinkDAO {
	private static final String STATEMENT_QUERY = "mybatis.xml.Link.query";

	@Override
	public Pagination<LinkVO> queryPage(LinkQuery query) {
		return queryPageTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public LinkVO queryOne(LinkQuery query) {
		List<LinkVO> list = queryListTemplate(STATEMENT_QUERY, query);
		if (list != null && !list.isEmpty()) {
			return list.get(0);
		}
		return null;
	}

	@Override
	public List<LinkVO> queryList(LinkQuery query) {
		return queryListTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public long queryNumber(LinkQuery query) {
		return queryNumberTemplate(STATEMENT_QUERY, query);
	}

	@Override
	public Map<String, Integer> queryStatistic() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int insert(Link info) {
		if (info != null) {
			int i = st.insert("mybatis.xml.Link.insertSelective", info);
			return i;
		}
		return 0;
	}

	@Override
	public int update(Link info) {
		if (info != null) {
			return st.update("mybatis.xml.Link.updateByPrimaryKeySelective",
					info);
		}
		return 0;
	}

	@Override
	public int delete(Link info) {
		if (info != null) {
			return st.delete("mybatis.xml.Link.deleteByPrimaryKey", info);
		}
		// sf.openSession().delete(user);
		return 0;
	}

}
